package com.kaisu.blog.application.user.convert;

import com.kaisu.blog.application.user.dto.RoleDTO;
import com.kaisu.blog.application.user.dto.UserDTO;
import com.kaisu.blog.domain.user.Role;
import com.kaisu.blog.domain.user.User;
import org.mapstruct.DecoratedWith;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingConstants;

/**
 * @author kaisu
 */
@Mapper(componentModel = MappingConstants.ComponentModel.SPRING)
@DecoratedWith(UserApplicationConvertDecorated.class)
public interface UserApplicationConvert {
    @Mapping(target = "avatar", source = "avatar.previewPath")
    @Mapping(target = "followers", ignore = true)
    @Mapping(target = "followings", ignore = true)
    UserDTO toDTO(User domain);

    Role map(RoleDTO dto);

    RoleDTO map(Role role);
}
